package o;

import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.MainThread;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import java.util.Calendar;
import java.util.Locale;

public class ebn implements AccountBussinessListener, a {
    private static final ebn ॱ = new ebn();
    private int ʼ = 0;
    private Calendar ˊ;
    private Handler ˋ = new Handler(Looper.getMainLooper());
    private ebr ˎ;
    private boolean ˏ;

    private ebn() {
    }

    public static ebn ॱ() {
        return ॱ;
    }

    @MainThread
    public void ˎ() {
        eoj.ˋ().ˎ("login_report_key", this);
    }

    @MainThread
    public void ॱ(Activity activity) {
        if (ˎ(activity)) {
            Logger.ˎ("LoginReportManager", "report by activity resume");
            ॱ(dgm.ˎ(activity));
        }
    }

    private void ˋ() {
        this.ˏ = false;
        this.ʼ = 0;
        this.ˊ = null;
        if (this.ˎ != null) {
            this.ˎ.ˊ();
            this.ˎ = null;
        }
    }

    public void onAccountBusinessResult(final ccp o_ccp) {
        this.ˋ.post(new Runnable(this) {
            final /* synthetic */ ebn ˏ;

            public void run() {
                if (102 == o_ccp.ˎ) {
                    this.ˏ.ˏ();
                } else if (103 == o_ccp.ˎ) {
                    this.ˏ.getAttrName();
                }
            }
        });
    }

    private void ˏ() {
        ˋ();
        this.ˏ = true;
        Activity ʻॱ = AbstractBaseActivity.ʻॱ();
        if (ˎ(ʻॱ)) {
            Logger.ˎ("LoginReportManager", "report by account login");
            ॱ(dgm.ˎ(ʻॱ));
        }
    }

    private void ˊ() {
        ˋ();
    }

    public void ॱ(BaseRequest o_cvu, ResponseBean responseBean) {
        this.ʼ = 0;
        this.ˊ = null;
    }

    public void ˎ(BaseRequest o_cvu, ResponseBean responseBean) {
        this.ʼ = 2;
        this.ˊ = Calendar.getInstance();
    }

    private void ॱ(int i) {
        this.ʼ = 1;
        this.ˎ = new ebr(this);
        this.ˎ.ˏ("9", "LOGIN", i);
    }

    private boolean ˎ(Activity activity) {
        boolean z = (activity == null || !this.ˏ) ? false : this.ʼ == 0 || (this.ʼ == 2 && ॱ(Calendar.getInstance()));
        if (Logger.ˎ()) {
            boolean z2;
            String str = "LoginReportManager";
            Locale locale = Locale.ENGLISH;
            String str2 = "activity exists:%s mIsLoggedIn:%s mReportStatus:%s result:%s";
            Object[] objArr = new Object[4];
            if (activity != null) {
                z2 = true;
            } else {
                z2 = false;
            }
            objArr[0] = Boolean.valueOf(z2);
            objArr[1] = Boolean.valueOf(this.ˏ);
            objArr[2] = Integer.valueOf(this.ʼ);
            objArr[3] = Boolean.valueOf(z);
            Logger.ˎ(str, String.format(locale, str2, objArr));
        }
        return z;
    }

    private boolean ॱ(Calendar calendar) {
        if (this.ˊ == null || calendar == null) {
            return true;
        }
        int i = this.ˊ.get(6);
        int i2 = this.ˊ.get(1);
        int i3 = calendar.get(6);
        if (i2 == calendar.get(1) && i == i3) {
            return false;
        }
        return true;
    }
}
